<html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">

<title>Cetak Data (<?php echo $engineReturn["title"]?>)</title>
<link href="<?php echo $engineTemplate?>css/style.css?<?php echo rand(20, 100);?>" rel="stylesheet" type="text/css" />
<meta content="" name="description">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="2 days" name="revisit-after">
<meta content="all,index,follow" name="robots">
<meta content="TRUE" name="MSSmartTagsPreventParsing">
<meta http-equiv="Content-Language" content="en-us">

<meta content="Global" name="Distribution">
<meta content="General" name="Rating">
<link href="images/favicon.ico" type="image/x-icon" rel="Shortcut Icon">

<style type="text/css">


body {
    background-color: #FFFFFF;
    font-family: Arial,Helvetica,sans-serif;
    font-size: 12px;
    margin: 0;
    padding: 0;
    text-align: center;
}


.no-style {
    background: none repeat scroll 0 0 transparent;
    border: medium none;
    border-collapse: collapse;
    margin: 0;
    padding: 0;
	font-family: Arial,Helvetica,sans-serif;
    font-size: 12px;
}


.rapor {
    border-collapse: collapse;
    border-color: #000000;
    border-style: solid;
    border-width: 1px;
    font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
    font-size: 10px;
    text-align: left;
}

</style>

</head>
<body onLoad="window.print();">
<div class="box-head">
	<h2 class="left">
		Cetak Data - <?php echo $engineReturn["title"]?>
	</h2>
</div>
<?php
	if(isset($engineReturn['record']['msg']) && is_array($engineReturn['record']['msg']))
	$total		= $engineReturn['record']['recTotal'];
	$startOri	= $engineReturn['record']['recStart'];
	$count		= $engineReturn['record']['recPage'];
	$res	= $engineReturn['record']['records'];
	if(count($res)>0)
	{
		echo "<table class='table'>";
		echo "<tr>";
			echo "<th rowspan='2'>";
			echo "</th>";
			foreach($engineReturn['record']['fieldSetting'] as $i=>$v)
			{
//				if($v['view'])
				{
					switch($v['input'])
					{
						case "medium_table":
						case "advance_table":
							$rs = count($res[0][$v['name']][1]);
							echo "<th colspan='".$rs."'>";
								echo $v['text'];
							echo "</th>";
						break;
						default:
							echo "<th rowspan='2'>";
								echo $v['text'];
							echo "</th>";
						break;
					}
				}
			}
		echo "</tr>";
		echo "<tr>";
			foreach($engineReturn['record']['fieldSetting'] as $i=>$v)
			{
//				if($v['view'])
				{
					switch($v['input'])
					{
						case "medium_table":
						case "advance_table":
							foreach($res[0][$v['name']][1] as $fv)
							{
								echo "<th>";
									echo $fv;
								echo "</th>";
							}
						break;
						default:
						break;
					}
				}
			}
		echo "</tr>";
		for($i = 0; $i<count($res); $i++)
		{
			$id	= $res[$i][$engineReturn['record']['fieldSetting'][0]['name']];
			echo "<tr>";
				echo "<td>".($startOri+$i+1)."</td>";
				foreach($engineReturn['record']['fieldSetting'] as $v)
				{
					$fieldName	= $v['name'];
//					if($v['view'])
					{
						switch($v['input'])
						{
							case "text":
							case "text_area":
								echo "<td class='tdGrid'>";
										echo $res[$i][$fieldName];
							break;
							case "hidden":
							case "text_primary":
							case "password":
							case "text_area_plus_editor":
								echo "<td>";
									echo $res[$i][$fieldName];
							break;
							case "checkbox":
								echo "<td>";
								if(is_array($res[$i][$fieldName]))
								{
									foreach($res[$i][$fieldName] as $v)
									{
										echo $v.", ";
									}
								}
							break;
							case "image":
								echo "<td>";
								if($res[$i][$fieldName]!="")
									echo "<div class='defContainerImage'>"
										."<img src='".$res[$i][$fieldName]."'>"
										."</div>";
							break;
							case "file":
								echo "<td>";
								if($res[$i][$fieldName]!="")
									echo "<a href='".$res[$i][$fieldName]."' target='_SELF'>"
										."DOWNLOAD</a>";
							break;
							case "radio":
							case "select":
								echo "<td class='tdGrid'>";
													if(isset($res[$i][$fieldName][1]))
														echo $res[$i][$fieldName][1];
													else
														echo $res[$i][$fieldName][0];
							break;
							case "simple_table":
								echo "<td class='tdGrid'>";
										if(isset($res[$i][$fieldName]['dataRec']))
											echo $res[$i][$fieldName]['dataRec'];
										else
											echo "-";
							break;
							case "medium_table":
							case "advance_table":
								$rs = count($res[$i][$fieldName][1]);
									if(isset($res[$i][$fieldName][0][0]) && (is_array($res[$i][$fieldName][0][0])))
									{
											foreach($res[$i][$fieldName][0][0] as $t)
											{
												echo "<td>".$t."</td>";
											}
									}
									else
									{
										echo "<td colspan='$rs'>";
									}
							break;
						}
						echo "</td>";
					}
				}
			echo "</tr>";
		}
	echo "</table>";
	}
	?>
	</body>
</html>
